package luogu;

import java.util.Scanner;

public class P1518 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][] arr = new char[10][10];
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int i = 0; i < 10; i++) {
            String s = sc.next();
            for (int j = 0; j < 10; j++) {
                arr[i][j] = (s.charAt(j));
                if (arr[i][j] == 'C') {
                    x1 = i;
                    y1 = j;
                }
                if (arr[i][j] == 'F') {
                    x2 = i;
                    y2 = j;
                }
            }
        }
        int f1 = 0;
        int f2 = 0;
        int count = 0;
        int c = 0;
        for (int i = 0; ;i++) {
            if (x1 == x2 && y1 == y2){
                System.out.println(count);
                break;
            }
            if (f1 == 0 && count == i){
                if (x1 == 0 || arr[x1 - 1][y1] == '*'){
                    f1 = 1;
                }else {
                    x1--;
                }
                count++;
            }
            if (f1 == 1 && count == i){
                if (y1 == 9 || arr[x1][y1 + 1] == '*'){
                    f1 = 2;
                }else {
                    y1++;
                }
                count++;
            }
            if (f1 == 2 && count == i){
                if (x1 == 9 || arr[x1 + 1][y1] == '*'){
                    f1 = 3;
                }else {
                    x1++;
                }
                count++;
            }
            if (f1 == 3 && count == i){
                if (y1 == 0 || arr[x1][y1 - 1] == '*'){
                    f1 = 0;
                }else {
                    y1--;
                }
                count++;
            }
            if (f2 == 0 && c == i){
                if (x2 == 0 || arr[x2 - 1][y2] == '*'){
                    f2 = 1;
                }else {
                    x2--;
                }
                c++;
            }
            if (f2 == 1 && c == i){
                if (y2 == 9 || arr[x2][y2 + 1] == '*'){
                    f2 = 2;
                }else {
                    y2++;
                }
                c++;
            }
            if (f2 == 2 && c == i){
                if (x2 == 9 || arr[x2 + 1][y2] == '*'){
                    f2 = 3;
                }else {
                    x2++;
                }
                c++;
            }
            if (f2 == 3 && c == i){
                if (y2 == 0 || arr[x2][y2 - 1] == '*'){
                    f2 = 0;
                }else {
                    y2--;
                }
                c++;
            }
            if (i >= 160000){
                System.out.println(0);
                break;
            }
        }
    }
}
